﻿using Microsoft.AspNetCore.Mvc;
using WMS.FC.Application.Menu.Interface;
using WMS.FC.Domain.DataTransferObject.Menu;
using WMS.FC.Infrastructure.Filter;

namespace WMS.FC.WebApi.Controllers
{
    /// <summary>
    /// 菜单控制器
    /// </summary>
    public class MenuController : BaseConroller
    {
        /// <summary>
        /// 菜单服务
        /// </summary>
        protected readonly IMenuService menuService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="menuService"></param>
        public MenuController(IMenuService menuService)
        {
            this.menuService = menuService;
        }

        /// <summary>
        /// 获取菜单列表
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetMenuList(GetMenuListDTO dTO)
        {
            var response = await menuService.GetMenuList(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 获取全部菜单列表
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetAllMenuList(GetMenuListDTO dTO)
        {
            var response = await menuService.GetAllMenuList(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 获取菜单配置
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GetMenuConfig(GetMenuConfigDTO dTO)
        {
            var response = await menuService.GetMenuConfig(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 添加菜单
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> AddMenu(AddMenuDTO dTO)
        {
            var response = await menuService.AddMenu(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 编辑菜单
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> EditMenu(EditMenuDTO dTO)
        {
            var response = await menuService.EditMenu(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> DeleteMenu(DeleteMenuDTO dTO)
        {
            var response = await menuService.DeleteMenu(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 生成列
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> GenerateColumns(GenerateColumnDTO dTO)
        {
            var response = await menuService.GenerateColumns(dTO);
            return Ok(response);
        }

        /// <summary>
        /// 复制列
        /// </summary>
        /// <param name="dTO"></param>
        /// <returns></returns>
        [HttpPost]
        [TypeFilter(typeof(WMSFilter))]
        public async Task<IActionResult> CopyColumns(CopyColumnDTO dTO)
        {
            var response = await menuService.CopyColumns(dTO);
            return Ok(response);
        }
    }
}
